Skip to content

all: enable makezero errchkjson noctx linters - #23174

Open
Sahil-4555 wants to merge 6 commits into
erigontech:mainfrom
Sahil-4555:linter/enable-makezero-errchkjson-noctx
Open

all: enable makezero errchkjson noctx linters#23174
Sahil-4555 wants to merge 6 commits into
erigontech:mainfrom
Sahil-4555:linter/enable-makezero-errchkjson-noctx

Conversation

@Sahil-4555

Copy link
Copy Markdown
Collaborator

Enables 3 bug-catching linter rules in .golangci.yml (makezero, errchkjson, and noctx) and resolves all existing violations across the codebase to ensure continuous CI protection against subtle runtime bugs.

1. makezero

  • What it prevents: Prevents silent slice corruption where make([]T, n) is followed by append(), which unintentionally prepends n zero-value items at the beginning of a slice.
  • Benefits: Guarantees slice allocations in Erigon are safe and clean, ensuring new code additions cannot introduce zero-padded array bugs into memory or state processing logic.

2. errchkjson

  • What it prevents: Prevents unhandled JSON serialization failures from json.Marshal, json.MarshalIndent, or json.Encoder.Encode failing silently when structs contain unsupported types, custom marshalers, or map keys.
  • Benefits: Improves API reliability and logging accuracy by ensuring JSON encoding errors in RPC, REST endpoints, and tools are caught and logged rather than producing corrupt/empty payloads.

3. noctx

  • What it prevents: Prevents network request hangs and uncancelable HTTP/socket operations created with http.NewRequest instead of context-aware functions.
  • Benefits: Ensures HTTP requests respect parent context timeouts and cancellation signals, preventing leaking goroutines and stuck network calls under heavy load or shutdown.

@Sahil-4555
Sahil-4555 force-pushed the linter/enable-makezero-errchkjson-noctx branch 2 times, most recently from 0e41ec1 to 8f05b71 Compare August 11, 2026 11:14
Comment thread cl/beacon/beaconhttp/api_test.go Outdated
Comment thread cl/beacon/handler/blobs.go Outdated
Comment thread cl/beacon/router.go Outdated
Comment thread cl/clparams/initial_state/initial_state.go Outdated
Comment thread cl/sentinel/handshake/handshake.go Outdated
@Sahil-4555
Sahil-4555 force-pushed the linter/enable-makezero-errchkjson-noctx branch from 8f05b71 to 690cc6b Compare August 12, 2026 04:23
Comment thread cl/beacon/beacontest/harness.go Outdated
Comment thread cl/beacon/handler/duties_proposer_test.go
Comment thread cl/beacon/router.go
Comment thread cl/p2p/p2p_test.go Outdated
Comment thread cmd/capcli/cli.go Outdated
Comment thread cmd/capcli/cli.go Outdated
Comment thread cl/beacon/router.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants